package com.sunfeng.netty.atguigu.bytebase;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * @author 孙峰
 * @Description: TODO
 * @date 2020/12/11 14:55
 */
public class Demo03 {
    public static void main(String[] args) {
        Charset utf8 = StandardCharsets.UTF_8;
        ByteBuf buf = Unpooled.copiedBuffer("Netty in Action rocks!", utf8);
        System.out.println((char)buf.readByte());
        int readerIndex = buf.readerIndex();
        int writerIndex = buf.writerIndex();
        System.out.println(readerIndex);
        System.out.println( writerIndex);
        buf.writeByte((byte)'?');
        System.out.println(buf.readerIndex());
        System.out.println( buf.writerIndex());
        assert readerIndex == buf.readerIndex();
        assert writerIndex != buf.writerIndex();
    }
}
